package drds.configuration.db.xml_mapping.dynamic_tag.tag_handler;

//import tool.plus.db.xml_mapping.dynamic_tag.sql_template.XmlMapperBuilder;

import drds.configuration.db.xml_mapping.dynamic_tag.sql_template.XmlMapperBuilder;
import drds.configuration.db.xml_mapping.dynamic_tag.tag.CompositeTag;
import drds.configuration.db.xml_mapping.dynamic_tag.tag.ForEachTag;
import drds.configuration.db.xml_mapping.dynamic_tag.tag.Tag;
import drds.configuration.db.xml_mapping.dynamic_tag.xml_node.XmlNode;

import java.util.List;

//import tool.plus.db.xml_mapping.dynamic_tag.tag.ForEachTag;

public class ForEachTagHandler implements TagHandler {
    private XmlMapperBuilder xmlMapperBuilder;

    public ForEachTagHandler(XmlMapperBuilder xmlMapperBuilder) {
        this.xmlMapperBuilder = xmlMapperBuilder;
    }

    @Override
    public void handleNode(XmlNode xmlNodeToHandle, List<Tag> tagList) {
        CompositeTag compositeTag = xmlMapperBuilder.parseTags(xmlNodeToHandle);
        //
        String collection = xmlNodeToHandle.getStringAttribute("collection");
        String itemAlias = xmlNodeToHandle.getStringAttribute("itemAlias");
        //
        String open = xmlNodeToHandle.getStringAttribute("open");
        String separator = xmlNodeToHandle.getStringAttribute("separator");
        String close = xmlNodeToHandle.getStringAttribute("close");

        ForEachTag forEachTag = new ForEachTag(xmlMapperBuilder.configuration, compositeTag, collection, itemAlias, open, separator, close);
        tagList.add(forEachTag);
    }
}
